package com.thrsdk.ui.dialog;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.thrsdk.constants.AppConfig;

public class SwitchAccountdialog extends Dialog implements View.OnClickListener {
    private Context mContext;
    private View mView;
    private SwitchAccountdialoglistener mSwitchAccountlistener;
    private Button dialog_exit_account;
    private Button dialog_cancel;

    public SwitchAccountdialog(Context context, SwitchAccountdialoglistener exitListener) {
        super(context, AppConfig.resourceId(context,
                "thf_MyDialog", "style"));
        this.mContext = context;
        this.mSwitchAccountlistener = exitListener;
        this.mView = LayoutInflater.from(context).inflate(
                AppConfig.resourceId(context, "thf_switch_dialog", "layout"),
                null);
    }

    public interface SwitchAccountdialoglistener {
        public void onClickSwitchAccount();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(mView);
        dialog_exit_account = (Button) findViewById(AppConfig.resourceId(mContext, "dialog_exit_account", "id"));
        dialog_cancel = (Button) findViewById(AppConfig.resourceId(mContext, "dialog_cancel", "id"));
        dialog_exit_account.setOnClickListener(this);
        dialog_cancel.setOnClickListener(this);
        this.setCancelable(false);
        this.setCanceledOnTouchOutside(false);
    }

    @Override
    public void onClick(View v) {

        if (v == dialog_exit_account) {
            dismiss();
            if (null != mSwitchAccountlistener) {
                mSwitchAccountlistener.onClickSwitchAccount();
            }
        } else if (v == dialog_cancel) {
            dismiss();

        }

    }

}
